package net.xdclass.service.fallback;

import feign.hystrix.FallbackFactory;
import net.xdclass.service.service.ProductClient;
import org.springframework.stereotype.Component;

/**
 * author: 何建文
 * create: 2020-07-18 19:51
 * description: 针对商品服务做降级处理，使用FallbackFactory模式，可以跟踪异常
 **/
@Component
public class ProductFegnFactory implements FallbackFactory<ProductClient> {

    private final ProductFeignFallback productFeignFallback;

    public ProductFegnFactory(ProductFeignFallback productFeignFallback) {
        this.productFeignFallback = productFeignFallback;
    }

    @Override
    public ProductClient create(Throwable cause) {
        cause.printStackTrace();
        return productFeignFallback;
    }
}
